package java15;

public class TextBlockSample {

    public static void main(String[] args) {
        // =================================
        // Text Block 文本块
        // 1. 以"""开头, 新起一行作为文本内容的起始
        // 2. 以"""结尾, 紧跟文本内容作为结束, 如果断行, 则文本内容也有一个空行
        // 3. 如果行内容过长, 可以使用“\”进行断行编辑, 文本内容的结果不会换行
        // 4. 每行字符末尾的空白会被删除
        // 5. 每行字符开始共有的空白会被删除, 只保留相对缩进
        // 6. 如果不想删除字符末尾的空白, 可以使用“\s”
        // 7. formatted可以对字符串进行格式化
        // =================================
        String data;
        /*
         * 结果:
         * >This is the first line
         * >This is the second line
         */
        data = """
                This is the first line
                This is the second line""";
        /*
         * 结果:
         * >This is the first line
         * >This is the second line
         * >(空行)
         */
        data = """
                This is the first line
                This is the second line
                """;
        /*
         * 结果:
         * >This is the first line, but the content is too long, it is written in a new line
         * >This is the second line
         */
        data = """
                This is the first line, \
                but the content is too long, \
                it is written in a new line
                This is the second line""";
        /*
         * 结果:
         * >This is the first line
         * >This is the second line
         */
        data = """
                This is the first line   
                This is the second line      """;
        /*
         * 结果:
         * >This is the first line
         * > This is the second line
         */
        data = """
                This is the first line   
                 This is the second line      """;
        /*
         * 结果:
         * >This is the first line_
         * >This is the second line
         */
        data = """
                This is the first line \s
                This is the second line""";
        /*
         * 结果:
         * >{
         * >    "name": "admin",
         * >    "mail": "admin@mail.com",
         * >    "age": 18
         * >}
         * >
         */
        data = """
                {
                    "name": "admin",
                    "mail": "%s",
                    "age": %d
                }
                """.formatted("admin@mail.com", 18);
    }

}